import request from '@/utils/request'

// ==================== 面试时段管理相关API ====================

// 查询面试时段列表
export function listInterviewSlot(query) {
  return request({
    url: '/campus/interviewSlot/list',
    method: 'get',
    params: query
  })
}

// 获取面试时段详细信息
export function getInterviewSlot(slotId) {
  return request({
    url: '/campus/interviewSlot/' + slotId,
    method: 'get'
  })
}

// 新增面试时段
export function addInterviewSlot(data) {
  return request({
    url: '/campus/interviewSlot',
    method: 'post',
    data: data
  })
}

// 修改面试时段
export function updateInterviewSlot(data) {
  return request({
    url: '/campus/interviewSlot',
    method: 'put',
    data: data
  })
}

// 删除面试时段
export function deleteInterviewSlot(slotIds) {
  return request({
    url: '/campus/interviewSlot/' + slotIds,
    method: 'delete'
  })
}

// 创建面试时段
export function createInterviewSlot(data) {
  return request({
    url: '/campus/interviewSlot/create',
    method: 'post',
    data: data
  })
}

// 批量创建面试时段
export function batchCreateInterviewSlots(data) {
  return request({
    url: '/campus/interviewSlot/batchCreate',
    method: 'post',
    data: data
  })
}

// 根据社团ID查询面试时段
export function getSlotsByClub(clubId) {
  return request({
    url: '/campus/interviewSlot/club/' + clubId,
    method: 'get'
  })
}

// 根据招聘ID查询面试时段
export function getSlotsByRecruitment(recruitmentId) {
  return request({
    url: '/campus/interviewSlot/recruitment/' + recruitmentId,
    method: 'get'
  })
}

// 查询可用的面试时段
export function getAvailableSlots(recruitmentId, date) {
  return request({
    url: '/campus/interviewSlot/available',
    method: 'get',
    params: {
      recruitmentId: recruitmentId,
      date: date
    }
  })
}

// 检查时段冲突
export function checkTimeConflict(data) {
  return request({
    url: '/campus/interviewSlot/checkConflict',
    method: 'get',
    params: data
  })
}

// 更新时段容量
export function updateSlotCapacity(slotId, change) {
  return request({
    url: '/campus/interviewSlot/updateCapacity/' + slotId,
    method: 'put',
    params: {
      change: change
    }
  })
}

// 关闭面试时段
export function closeInterviewSlot(slotId) {
  return request({
    url: '/campus/interviewSlot/close/' + slotId,
    method: 'put'
  })
}

// 重新开放面试时段
export function reopenInterviewSlot(slotId) {
  return request({
    url: '/campus/interviewSlot/reopen/' + slotId,
    method: 'put'
  })
}

// 获取社团的面试时段统计
export function getClubSlotStatistics(clubId) {
  return request({
    url: '/campus/interviewSlot/statistics/club/' + clubId,
    method: 'get'
  })
}

// 获取时段的详细统计
export function getSlotStatistics(slotId) {
  return request({
    url: '/campus/interviewSlot/statistics/' + slotId,
    method: 'get'
  })
}

// 获取时段的预约数量
export function getSlotBookingCount(slotId) {
  return request({
    url: '/campus/interviewSlot/bookingCount/' + slotId,
    method: 'get'
  })
}

// 检查时段是否可预约
export function isSlotAvailable(slotId) {
  return request({
    url: '/campus/interviewSlot/isAvailable/' + slotId,
    method: 'get'
  })
}

// 复制面试时段
export function copyInterviewSlot(data) {
  return request({
    url: '/campus/interviewSlot/copy',
    method: 'post',
    data: data
  })
}

// 查询即将开始的面试时段
export function getUpcomingSlots(hours = 24) {
  return request({
    url: '/campus/interviewSlot/upcoming',
    method: 'get',
    params: {
      hours: hours
    }
  })
}

// 查询已过期的面试时段
export function getExpiredSlots() {
  return request({
    url: '/campus/interviewSlot/expired',
    method: 'get'
  })
}

// 自动更新过期时段状态
export function updateExpiredSlotsStatus() {
  return request({
    url: '/campus/interviewSlot/updateExpiredStatus',
    method: 'put'
  })
}
